package edu.gyc.hiseckill.code;

import java.util.Date;

//传统的时间加随机数
public class SeqUtil {
    public static int count = 0;
    public static String autoStr = null;

    //生成订单编号-方式一
    public static synchronized String generateOrderCode() {
        count++;
        if(count>=100000){
            count=1;
        }
        autoStr = String.valueOf(count);
        //TODO:时间戳+N为随机数流水号
        return generateNumber(6);

    }

    //N为随机数流水号
    public static String generateNumber(final int num) {
        StringBuffer sb = new StringBuffer();
        for (int i = 1; i <= num-autoStr.length(); i++) {
            sb.append(0);
        }
        sb.append(autoStr);
        return sb.toString();
    }
}
